<c:if test="true"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:nxl="http://nuxeo.org/nxforms/layout"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxp="http://nuxeo.org/nxweb/pdf"
  xmlns:a4j="http://richfaces.org/a4j">
<c:set var="displaySubLabels" value="#{not widgetProperty_hideSubLabels}" />
<c:set var="showHeader" value="#{widget.handlingLabels and (not empty widget.subWidgets or widgetProperty_showIfEmpty)}" />
<c:set var="containerWidgetProps" value="#{widget.properties}" />
<c:if test="#{nxl:isLikePlainMode(widget.mode)}">
  <c:if test="#{showHeader}">
    <c:if test="#{widget.translated}">#{messages[widget.label]}</c:if>
    <c:if test="#{not widget.translated}">#{widget.label}</c:if>
  </c:if>
  <nxl:subWidget>
    <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
    <c:set var="addForm" value="#{containerWidgetProps[addFormName] or widgetControl_requireSurroundingForm}" />
    <nxu:form id="#{widget.id}_form"
      skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
      useAjaxForm="#{widgetControl_useAjaxForm}"
      disableMultipartForm="#{widgetControl_disableMultiPartForm}"
      disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
      <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
    </nxu:form>
  </nxl:subWidget>
</c:if>
<c:if test="#{widget.mode == 'pdf'}">
  <nxp:html>
    <c:if test="#{showHeader}">
      <ui:include src="/widgets/incl/widget_label_template.xhtml" />
    </c:if>
    <nxl:subWidget>
      <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
      <nxu:form id="#{widget.id}_form"
        skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
        useAjaxForm="#{widgetControl_useAjaxForm}"
        disableMultipartForm="#{widgetControl_disableMultiPartForm}"
        disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
        <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
      </nxu:form>
    </nxl:subWidget>
  </nxp:html>
</c:if>
<c:if test="#{not nxl:isLikePlainMode(widget.mode) and widget.mode != 'pdf'}">

  <c:set var="isEditMode" value="#{widget.mode == 'edit'}" />
  <c:set var="defaultAjaxPanelId" value="#{widget.id}_panel"/>
  <c:set var="ajaxPanelId" value="#{nxu:test(empty widgetProperty_ajaxPanelId, defaultAjaxPanelId, widgetProperty_ajaxPanelId)}" />

  <a4j:outputPanel id="#{ajaxPanelId}" layout="block">

  <ui:decorate template="/widgets/incl/foldable_box_template.xhtml">
    <ui:param name="hideHeader" value="#{not showHeader or (empty widget.label and not widgetProperty_foldable)}" />
    <ui:param name="foldable" value="#{widgetProperty_foldable}" />
    <ui:param name="foldedByDefault" value="#{widgetProperty_foldedByDefault}" />
    <ui:param name="foldableBoxStyleClass" value="widgetPanel containerWidgetPanel #{widgetProperty_styleClass}" />
    <ui:param name="headerStyleClass" value="widgetHeader #{nxu:test(widgetProperty_foldable, '', 'summaryTitle')} #{widgetProperty_headerStyleClass}" />

    <ui:define name="foldable_box_header_content">
      <ui:include src="/widgets/incl/widget_label_template.xhtml">
        <ui:param name="defaultLabel"
          value="#{foldable?messages['label.foldableBox.foldUnfold']:''}" />
        <ui:param name="labelStyleClass"
          value="#{widgetProperty_headerStyleClass}" />
      </ui:include>
    </ui:define>

    <ui:define name="foldable_box_content">

      <c:if test="#{showHeader and not empty widgetProperty_tip}">
        <nxu:set var="tip"
          value="#{nxu:test(widget.translated, messages[widgetProperty_tip], widgetProperty_tip)}"
          cache="true">
          <div class="tips">
            <h:outputText value="#{tip}" />
          </div>
        </nxu:set>
      </c:if>

      <c:choose>

        <c:when test="#{widgetProperty_display == 'table'}">
          <table class="dataTable widgetTable containerWidgetTable #{widgetProperty_subStyleClass}">
            <thead>
              <c:if test="#{displaySubLabels}">
                <tr>
                  <nxl:subWidget>
                    <th class="boldColumn containerLabel">
                      <c:if test="#{not widget.handlingLabels}">
                        <ui:include src="/widgets/incl/widget_label_template.xhtml">
                          <ui:param name="labelStyleClass"
                            value="boldLabel #{widgetProperty_subLabelStyleClass}" />
                        </ui:include>
                      </c:if>
                    </th>
                  </nxl:subWidget>
                </tr>
              </c:if>
            </thead>
            <tbody>
              <tr>
                <nxl:subWidget>
                  <td class="fieldColumn containerField">
                    <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
                    <nxu:form id="#{widget.id}_form"
                      skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
                      useAjaxForm="#{widgetControl_useAjaxForm}"
                      disableMultipartForm="#{widgetControl_disableMultiPartForm}"
                      styleClass="subWidgetForm"
                      disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
                      <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
                    </nxu:form>
                  </td>
                </nxl:subWidget>
              </tr>
            </tbody>
          </table>
        </c:when>

        <c:when test="#{widgetProperty_display == 'inline'}">
          <nxl:subWidget>
            <span class="containerSubWidget #{widgetProperty_subStyleClass}">
              <c:if test="#{displaySubLabels and not widget.handlingLabels}">
                <ui:include src="/widgets/incl/widget_label_template.xhtml">
                  <ui:param name="labelStyleClass"
                    value="boldLabel #{widgetProperty_subLabelStyleClass}" />
                </ui:include>
                <h:outputText value=" " />
              </c:if>
              <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
              <nxu:form id="#{widget.id}_form"
                skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
                useAjaxForm="#{widgetControl_useAjaxForm}"
                disableMultipartForm="#{widgetControl_disableMultiPartForm}"
                styleClass="subWidgetForm"
                disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
                <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
              </nxu:form>
            </span>
          </nxl:subWidget>
        </c:when>

        <c:when test="#{widgetProperty_display == 'block_top'}">
          <nxl:subWidget>
            <div class="containerSubWidget #{widgetProperty_subStyleClass}">
              <c:if test="#{displaySubLabels and not widget.handlingLabels}">
                <div>
                  <ui:include src="/widgets/incl/widget_label_template.xhtml">
                    <ui:param name="labelStyleClass"
                      value="boldLabel #{widgetProperty_subLabelStyleClass}" />
                  </ui:include>
                </div>
              </c:if>
              <div>
                <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
                <nxu:form id="#{widget.id}_form"
                  skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
                  useAjaxForm="#{widgetControl_useAjaxForm}"
                  disableMultipartForm="#{widgetControl_disableMultiPartForm}"
                  styleClass="subWidgetForm"
                  disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
                  <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
                </nxu:form>
              </div>
            </div>
          </nxl:subWidget>
        </c:when>

        <c:otherwise>

          <c:if test="#{not displaySubLabels}">
            <nxl:subWidget>
              <div class="containerField">
                <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
                <nxu:form id="#{widget.id}_form"
                  skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
                  useAjaxForm="#{widgetControl_useAjaxForm}"
                  disableMultipartForm="#{widgetControl_disableMultiPartForm}"
                  styleClass="subWidgetForm"
                  disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
                  <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
                </nxu:form>
              </div>
            </nxl:subWidget>
          </c:if>

          <c:if test="#{displaySubLabels}">
            <table class="widgetTable containerWidgetTable #{widgetProperty_subStyleClass}">
              <tbody>
                <nxl:subWidget>
                  <tr>
                    <td class="boldColumn containerLabel">
                      <c:if test="#{not widget.handlingLabels}">
                        <ui:include src="/widgets/incl/widget_label_template.xhtml">
                          <ui:param name="labelStyleClass"
                            value="boldLabel #{widgetProperty_subLabelStyleClass}" />
                        </ui:include>
                      </c:if>
                    </td>
                    <td class="fieldColumn containerField">
                      <c:set var="addFormName" value="nxw_addForm_#{widgetIndex}" />
                      <nxu:form id="#{widget.id}_form"
                        skip="#{!containerWidgetProps[addFormName] and !widgetControl_requireSurroundingForm}"
                        useAjaxForm="#{widgetControl_useAjaxForm}"
                        disableMultipartForm="#{widgetControl_disableMultiPartForm}"
                        styleClass="subWidgetForm"
                        disableDoubleClickShield="#{widgetControl_disableDoubleClickShield}">
                        <nxl:widget widget="#{widget}" value="#{fieldOrValue}" />
                      </nxu:form>
                    </td>
                  </tr>
                </nxl:subWidget>
              </tbody>
            </table>
          </c:if>
        </c:otherwise>

      </c:choose>

    </ui:define>
  </ui:decorate>

  </a4j:outputPanel>

</c:if>
</c:if>